package nio.one;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.nio.channels.FileChannel;

/*
    通道之间数据的转移
 */
public class ChannelTest05 {
    public static void main(String[] args) {
        try (
                //获取输入通道
                FileInputStream fis = new FileInputStream("E:\\mycode\\io\\src\\nio\\one\\test.txt");
                FileChannel fisChannel = fis.getChannel();
                //获取输出通道
                FileOutputStream fos = new FileOutputStream("E:\\mycode\\io\\src\\nio\\one\\test3.txt");
                FileChannel fosChannel = fos.getChannel()
        ) {
            //将fisChannel通道的数据转移到fosChannel通道的两种方法
//            fosChannel.transferFrom(fisChannel,fisChannel.position(),fisChannel.size());
            fisChannel.transferTo(fisChannel.position(),fisChannel.size(),fosChannel);
        } catch (Exception e) {
        }
    }
}
